<template>
  <div class="box-img">
    <img :src="videoItem.coverUrl" alt="">
    <div class="count">
      <i class="iconfont iconbofang"/>
      <span class="playCount">
        {{videoItem.playCount}}
      </span>
    </div>
    <span class="duration">{{videoItem.duration}}</span>
  </div>
  <p class="mv-name"><span class="mv" v-if="isMv">MV</span>{{videoItem.name}}</p>
  <p class="by-artist">
    <span class="by" v-if="!isMv">by</span>
    <span class="artist-name">{{videoItem.nickName}}</span>
  </p>

</template>

<script lang="ts">
import { ref, computed } from 'vue'
export default {
  name: 'Video',
  props: {
    videoItem: {
      type: Object,
      default: () => ({})
    }
  },
  setup (props) {
    const reg = ref(/[a-zA-Z]/g)
    const isMv = computed(() => !reg.value.test(props.videoItem.id))
    return {
      isMv
    }
  }
}
</script>

<style lang="scss" scoped>
.box-img {
  position: relative;
  border-radius: 5px;

  >img {
    width: 100%;
    border-radius: 5px;
  }

  .count {
    position: absolute;
    top: 6px;
    right: 8px;
    color: #fff;
    font-size: 12px;
    display: flex;
    align-items: center;

    >i {
      padding-right: 4px;
      font-size: 14px;
    }
  }

  .duration {
    position: absolute;
    bottom: 8px;
    right: 5px;
    color: #fff;
    font-size: 12px;
  }
}

.mv-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
  margin-top: 10px;
  margin-bottom: 6px;
  font-size: 15px;
  color: #333333;
  line-height: 1.2;
  cursor: pointer;

  .mv {
    display: inline-block;
    font-weight: 600;
    color: #ec4141;
    border: 1px solid #ec4141;
    border-radius: 3px;
    font-size: 12px;
    line-height: 1;
    margin-right: 4px;
  }
}

.by-artist {
  cursor: pointer;

  .by, .artist-name {
    color: #D0D0D0;
    padding-right: 6px;
    font-size: 12px;
    line-height: 1.2;
  }
}
</style>
